import java.util.Arrays;

public class InsertSort {
    public static void insertSort(int[] arr){
        for (int i = 1; i < arr.length; i++) {
            int j=i-1,inval=arr[i];
            if (arr[j]>inval){
                while(j>=0&&arr[j]>inval){
                    arr[j+1]=arr[j];
                    j--;
                }
                arr[j+1]=inval;
            }

        }
    }

    public static void main(String[] args) {
        int[] arr={8,4894,8468,4684,684,68468,4846,4,864,64,64,6,484,6,46,48,4,81,1,2,8,5,484,84,8,48,4};
        insertSort(arr);
        System.out.println(Arrays.toString(arr));
    }
}
